﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="overbrick.aspx.cs" Inherits="材料计算器.overbrick" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">
        function calculate() {
            //5%的损耗
            var pieceNum = Math.ceil((window.form1.tb_roomlen.value * window.form1.tb_roomwid.value * 1000000 * 1.05) / (window.form1.tb_len.value * window.form1.tb_wid.value * 1.0));
            window.form1.tb_num.value = pieceNum;
            window.form1.tb_totalP.value = Math.ceil(pieceNum * window.form1.tb_unitP.value);

        }
        function reset() {
            window.form1.tb_roomlen.value = ""
            window.form1.tb_roomwid.value = ""
            window.form1.tb_unitP.value = ""
            window.form1.tb_num.value = ""
            window.form1.tb_totalP.value = ""
        }
        function brickCodex() {
            switch (window.form1.select.selectedIndex) {
                case 0:
                    window.form1.tb_len.value = "300"
                    window.form1.tb_wid.value = "300"
                    break
                case 1:
                    window.form1.tb_len.value = "400"
                    window.form1.tb_wid.value = "400"
                    break
                case 2:
                    window.form1.tb_len.value = "500"
                    window.form1.tb_wid.value = "500"
                    break
                case 3:
                    window.form1.tb_len.value = "600"
                    window.form1.tb_wid.value = "600"
                    break
            }
        }
    </script>

    <style type="text/css">
        .style1
        {
            height: 21px;
            font-weight: bold;
        }
        .style2
        {
            height: 24px;
            width: 48%;
        }
        .style3
        {
            color: #FF0000;
        }
        .style4
        {
            height: 24px;
            width: 37%;
        }
        .style5
        {
            width: 37%;
        }
        .style6
        {
            width: 48%;
        }
        #Select1
        {
            width: 95px;
            height: 22px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center" style="width: 473px; margin-right: 0px">
        <table border="0" cellpadding="1" cellspacing="1" style="height: 564px; width: 89%">
            <tr>
                <td colspan="2" class="style1">
                    <div align="center" style="background-color: #3399FF; height: 25px;">
                        地砖计算器</div>
                </td>
            </tr>
            <tr>
                <td class="style4">
                </td>
                <td class="style2">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div align="left">
                        1、请输入房间信息</div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        房间长度：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_roomlen" runat="server"></asp:TextBox>
                        米<br />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="请输入正确数值"
                            ControlToValidate="tb_roomlen" ValidationExpression="^[1-9]+(.[0-9]*)?$"></asp:RegularExpressionValidator>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        房间宽度：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_roomwid" runat="server"></asp:TextBox>
                        米<br />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="tb_roomwid"
                            ErrorMessage="请输入正确数值" ValidationExpression="^[1-9]+(.[0-9]*)?$"></asp:RegularExpressionValidator>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div align="left">
                        2、请输入地板信息</div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        选择标准规格的地砖：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <select name="select" onclick="brickCodex()">
                            <option selected>300x300</option>
                            <option>400x400</option>
                            <option>500x500</option>
                            <option>600x600</option>
                        </select>毫米</div>
                </td>
            </tr>
            <tr>
                <td height="26" class="style5">
                    <div align="right">
                        地砖长度：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_len" runat="server">300</asp:TextBox>
                        毫米<br />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="tb_len"
                            ErrorMessage="请输入非零正整数" ValidationExpression="^\+?[1-9][0-9]*$"></asp:RegularExpressionValidator>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        地砖宽度：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_wid" runat="server">300</asp:TextBox>
                        毫米<br />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="tb_wid"
                            ErrorMessage="请输入非零正整数" ValidationExpression="^\+?[1-9][0-9]*$"></asp:RegularExpressionValidator>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        地砖单价：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_unitP" runat="server"></asp:TextBox>
                        元<br />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ControlToValidate="tb_unitP"
                            ErrorMessage="请输入正确数值" ValidationExpression="^[1-9]+(.[0-9]*)?$"></asp:RegularExpressionValidator>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div align="center">
                        <hr style="background-color: #9933FF; color: #9933FF;" />
                    </div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        您需要的地砖数量是：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_num" runat="server" ReadOnly="True" onFocus="this.select()"></asp:TextBox>
                        块</div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    <div align="right">
                        您需要的地砖总价是：</div>
                </td>
                <td class="style6">
                    <div align="left">
                        <asp:TextBox ID="tb_totalP" runat="server" ReadOnly="True" onFocus="this.select()"></asp:TextBox>
                        元</div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    &nbsp;
                </td>
                <td class="style6">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div align="center">
                        <input id="bt_cal" type="button" value="计算" onclick="calculate()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input id="bt_reset" type="button" value="重输" onclick="reset()" />&nbsp;&nbsp;
                    </div>
                </td>
            </tr>
            <tr>
                <td class="style5">
                    &nbsp;
                </td>
                <td class="style6">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div align="left">
                        <p class="style3">
                            声明：该计算器提供的结果仅供参考。购买时请以专业厂商提供的数据为准。</p>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
